package com.niit.controller.common;

import com.niit.model.ExamPaper;
import com.niit.model.PaperQuestion;
import com.niit.model.Student;
import com.niit.model.StudentPaperQuestionAnswer;
import com.niit.service.ExamService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.*;

/**
 * @author 王铭 20181620310021
 * #Date 2021/6/25 - 23:38
 */

@Controller
@SessionAttributes(value = {"examPaper"})
public class ExamController {
    ExamService examService;
    @Autowired
    public void setExamService(ExamService examService) {
        this.examService = examService;
    }




    @GetMapping("do-paper")
    public String doPaper(Model model, Long paperID, @ModelAttribute Student student){
        model.addAttribute(examService.doPaper(paperID ,student,1));//
        return "do-paper";
    }

    @PostMapping("do-paper/{next}")
    public String doPaper(Model model, Long paperID, @ModelAttribute Student student,@PathVariable("next") Integer q_next, StudentPaperQuestionAnswer studentPaperQuestionAnswer){
        model.addAttribute(examService.doPaper(paperID ,student,q_next,studentPaperQuestionAnswer));
        return "do-paper";
    }

}
